import 'package:ca_dsp_pro/src/common/db_item.dart';
import 'package:ca_dsp_pro/src/modules/level/my_level_controller.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

import '../../tool/assets.dart';

class MyLevel extends GainPageDelegate<MyLevelController> {
  @override
  Widget build(BuildContext context) {
    return Container(
        color: Color_bg_view,
        padding: const EdgeInsets.all(5),
        child: Obx(() {
          return Column(
            spacing: 5,
            children: [
              Expanded(
                child: Row(
                  spacing: 5,
                  children: globalController.rxModel.value.ch_list.map(($0) {
                    return Expanded(
                      child: Column(
                        children: [
                          Container(height: 10, color: Color($0.hex_line)),
                          Expanded(
                            child: Container(
                              child: DbItem(
                                  name: $0.name,
                                  max: $0.max_db,
                                  min: $0.min_db,
                                  value: $0.db,
                                  ison: $0.mute,
                                  radius: 0,
                                  onChanged: (value, issend) => controller.updateDB($0, value, isSend: issend),
                                  onTurnOn: (p0) => controller.updateMUTE($0)),
                            ),
                          )
                        ],
                      ),
                    );
                  }).toList(),
                ),
              ),
              SizedBox(
                height: 30,
                child: Row(
                  spacing: 5,
                  children: List.generate(controller.groupList.length, ($0) {
                    final group = controller.groupList[$0];
                    return Expanded(
                      child: Container(
                        color: group.select ? Color(group.ch1?.hex_line ?? 0xFF8D8D8D) : Color_bg_view2,
                        child: Material(
                          color: Colors.transparent,
                          child: InkWell(
                            onTap: () => controller.chooseGroup($0),
                            child: const Center(
                                child: Text('LINK',
                                    style: TextStyle(fontSize: 20, color: Colors.white, fontWeight: FontWeight.bold))),
                          ),
                        ),
                      ),
                    );
                  }),
                ),
              ),
            ],
          );
        }));
  }
}
